%%{init: {'themeVariables': { 'fontSize': '12px'}}}%%
graph TD
    classDef path fill:#eee,stroke:#000,color:#000
    classDef plan fill:#fff,stroke-width:1px,color:#000
    classDef itemplan fill:#fff,stroke-width:2px,color:#000
    classDef unbatchedplan fill:#dff,stroke-width:1px,color:#000
    classDef sideeffectplan fill:#fcc,stroke-width:2px,color:#000
    classDef bucket fill:#f6f6f6,color:#000,stroke-width:2px,text-align:left

    subgraph "Buckets for queries/v4/issue2210"
    Bucket0("Bucket 0 (root)<br /><br />1: <br />ᐳ: 9, 12, 13, 41, 42, 14, 15, 17<br />2: PgSelect[11]<br />ᐳ: Access[26]<br />3: Connection[16]<br />4: ConnectionItems[18]<br />ᐳ: Last[25], PgCursor[27]"):::bucket
    Bucket1("Bucket 1 (nullableBoundary)<br />Deps: 16, 18, 14, 27<br /><br />ROOT Connectionᐸ11ᐳ[16]"):::bucket
    Bucket3("Bucket 3 (listItem)<br />Deps: 14<br /><br />ROOT __Item{3}ᐸ18ᐳ[22]"):::bucket
    Bucket4("Bucket 4 (nullableBoundary)<br />Deps: 23, 14<br /><br />ROOT PgSelectSingle{3}ᐸsome_messagesᐳ[23]<br />1: <br />ᐳ: 28, 29, 30, 31<br />2: PgSelect[32]<br />3: PgSelectRows[37]<br />ᐳ: First[36], PgSelectSingle[38]"):::bucket
    Bucket5("Bucket 5 (nullableBoundary)<br />Deps: 38<br /><br />ROOT PgSelectSingle{4}ᐸtest_userᐳ[38]"):::bucket
    end
    Bucket0 --> Bucket1
    Bucket1 --> Bucket3
    Bucket3 --> Bucket4
    Bucket4 --> Bucket5

    %% plan dependencies
    PgSelect11[["PgSelect[11∈0] ➊<br />ᐸsome_messages+1ᐳ<br />More deps:<br />- Object[14]<br />- Constantᐸ50ᐳ[42]"]]:::plan
    PgFromExpression15{{"PgFromExpression[15∈0] ➊<br />More deps:<br />- Constantᐸ'0d126c0c-9710-478c-9aee-0be34b250573'ᐳ[41]"}}:::plan
    Lambda17{{"Lambda[17∈0] ➊<br />ᐸparseCursorᐳ"}}:::plan
    PgFromExpression15 & Lambda17 --> PgSelect11
    Connection16[["Connection[16∈0] ➊<br />ᐸ11ᐳ<br />Dependents: 3<br />More deps:<br />- Constantᐸ50ᐳ[42]"]]:::plan
    PgSelect11 & Lambda17 --> Connection16
    Object14{{"Object[14∈0] ➊<br />ᐸ{pgSettings,withPgClient}ᐳ<br />Dependents: 2"}}:::plan
    Access12{{"Access[12∈0] ➊<br />ᐸ2.pgSettingsᐳ"}}:::plan
    Access13{{"Access[13∈0] ➊<br />ᐸ2.withPgClientᐳ"}}:::plan
    Access12 & Access13 --> Object14
    Access9{{"Access[9∈0] ➊<br />ᐸ0.afterᐳ"}}:::plan
    __Value0["__Value[0∈0] ➊<br />ᐸvariableValuesᐳ"]:::plan
    __Value0 --> Access9
    __Value2["__Value[2∈0] ➊<br />ᐸcontextᐳ"]:::plan
    __Value2 --> Access12
    __Value2 --> Access13
    Access9 --> Lambda17
    ConnectionItems18[["ConnectionItems[18∈0] ➊<br />Dependents: 2<br />More deps:<br />- Connection[16]"]]:::plan
    Last25{{"Last[25∈0] ➊<br />More deps:<br />- ConnectionItems[18]"}}:::plan
    Access26{{"Access[26∈0] ➊<br />ᐸ11.cursorDetailsᐳ"}}:::plan
    PgSelect11 --> Access26
    PageInfo21{{"PageInfo[21∈1] ➊<br />More deps:<br />- Connection[16]"}}:::plan
    Access24{{"Access[24∈1] ➊<br />ᐸ16.hasNextPageᐳ<br />More deps:<br />- Connection[16]"}}:::plan
    __Item22[/"__Item[22∈3]<br />ᐸ18ᐳ<br />More deps:<br />- ConnectionItems[18]"\]:::itemplan
    PgSelectSingle23{{"PgSelectSingle[23∈3]<br />ᐸsome_messagesᐳ"}}:::plan
    __Item22 --> PgSelectSingle23
    PgSelect32[["PgSelect[32∈4]<br />ᐸtest_userᐳ<br />More deps:<br />- Object[14]"]]:::plan
    PgClassExpression31{{"PgClassExpression[31∈4]<br />ᐸ__some_mes...t_user_id”ᐳ"}}:::plan
    PgClassExpression31 --> PgSelect32
    PgClassExpression28{{"PgClassExpression[28∈4]<br />ᐸ__some_messages__.”id”ᐳ"}}:::plan
    PgSelectSingle23 --> PgClassExpression28
    PgClassExpression29{{"PgClassExpression[29∈4]<br />ᐸ__some_mes....”message”ᐳ"}}:::plan
    PgClassExpression28 o--o PgClassExpression29
    PgClassExpression30{{"PgClassExpression[30∈4]<br />ᐸ__some_mes...reated_at”ᐳ"}}:::plan
    PgClassExpression29 o--o PgClassExpression30
    PgSelectSingle23 --> PgClassExpression31
    First36{{"First[36∈4]"}}:::plan
    PgSelectRows37[["PgSelectRows[37∈4]"]]:::plan
    PgSelectRows37 --> First36
    PgSelect32 --> PgSelectRows37
    PgSelectSingle38{{"PgSelectSingle[38∈4]<br />ᐸtest_userᐳ"}}:::plan
    First36 --> PgSelectSingle38
    PgClassExpression39{{"PgClassExpression[39∈5]<br />ᐸ__test_user__.”id”ᐳ"}}:::plan
    PgSelectSingle38 --> PgClassExpression39
    PgClassExpression40{{"PgClassExpression[40∈5]<br />ᐸ__test_user__.”name”ᐳ"}}:::plan
    PgClassExpression39 o--o PgClassExpression40

    %% define steps
    classDef bucket0 stroke:#696969
    class Bucket0,__Value0,__Value2,Access9,PgSelect11,Access12,Access13,Object14,PgFromExpression15,Connection16,Lambda17,ConnectionItems18,Last25,Access26 bucket0
    classDef bucket1 stroke:#00bfff
    class Bucket1,PageInfo21,Access24 bucket1
    classDef bucket3 stroke:#ffa500
    class Bucket3,__Item22,PgSelectSingle23 bucket3
    classDef bucket4 stroke:#0000ff
    class Bucket4,PgClassExpression28,PgClassExpression29,PgClassExpression30,PgClassExpression31,PgSelect32,First36,PgSelectRows37,PgSelectSingle38 bucket4
    classDef bucket5 stroke:#7fff00
    class Bucket5,PgClassExpression39,PgClassExpression40 bucket5

